package com.leaf.spring.y201907.day12.zk;

import java.util.List;

import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.ZooKeeper.States;

public class ZookeeperConnectionTest {

	public static void main(String[] args) throws Exception {

		ZookeeperWatcher watcher = new ZookeeperWatcher();

		final ZooKeeper zk = new ZooKeeper("192.168.90.49:2181", 5000, watcher);
		
		new Thread(() -> {

			try {
				while (!watcher.isConnected()) {
					System.out.println("12");
					Thread.sleep(1000);
				}

				List<String> children = zk.getChildren("/", true);

				System.out.println("根目录下子节点：" + children.toString());
				
				
				
			} catch (Exception e) {
				e.printStackTrace();
			}
		}).start();

		System.in.read();

	}

}
